home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Graphics / TVPaint / Rexx / LineCut.rx < prev    next >
Encoding:
Text File  |  1995-11-07  |  929 b   |  107 lines

  1. /*
  2.     param line
  3.  
  4.     Draw a cut line
  5.     Modify l: the lenght of the step on the line
  6.  
  7. */
  8.  
  9. address 'rexx_TVPaint'
  10.     
  11.     parse ARG m x1 y1 x2 y2 b
  12.     if(m~='Line')then
  13.     do
  14.         tv_warn 'I need LINE parameters'
  15.         exit
  16.     end
  17.  
  18.  
  19.     l=20
  20.  
  21.  
  22.     tv_UpdateUndo
  23.     x=x1
  24.     y=y1
  25.  
  26.     iy=1
  27.     dy=y2-y1
  28.     if (dy<0) then
  29.     do
  30.         dy=-dy
  31.         iy=-1
  32.     end
  33.  
  34.  
  35.     ix=1
  36.     dx=x2-x1
  37.     if (dx<0) then
  38.     do
  39.         dx=-dx
  40.         ix=-1
  41.     end
  42.  
  43.     xb=x
  44.     yb=y
  45.     xa=x
  46.     ya=y
  47.     c=1
  48.  
  49.     if (dx>dy) then
  50.     do
  51.         d=dx
  52.         do while (x~==x2)
  53.  
  54.             x=x+ix
  55.             d=d-dy
  56.  
  57.             if (d<0) then
  58.             do
  59.                 y=y+iy
  60.                 d=d+dx
  61.             end
  62.  
  63.             if((x%l)*l == x) then
  64.             do
  65.                 if (c==1) then
  66.                 do
  67.                     tv_line xb yb x y b
  68.                     c=0
  69.                 end
  70.                 else c=1
  71.  
  72.                 xb=x
  73.                 yb=y
  74.             end
  75.         end
  76.     end
  77.     else
  78.     do
  79.         d=dy
  80.         do while (y ~==y2)
  81.  
  82.             y=y+iy
  83.             d=d-dx
  84.  
  85.             if (d<0) then
  86.             do
  87.                 x=x+ix
  88.                 d=d+dy
  89.             end
  90.             if((y%l)*l == y) then
  91.             do
  92.  
  93.                 if (c==1) then
  94.                 do
  95.                     tv_line xb yb x y b
  96.                     c=0
  97.                 end
  98.                 else c=1
  99.  
  100.                 xb=x
  101.                 yb=y
  102.             end
  103.         end
  104.     end
  105.  
  106.  
  107.